import React from 'react';
import ReactDOM from 'react-dom';
import { HashRouter, Route, Switch, Redirect, BrowserRouter } from 'react-router-dom';
import { Provider } from "react-redux";

import App from "./component/App";
import store from './store';
import { commonRoutes } from './routers';
import "./css/common.scss";
import Axios from "./api";
import qs from "qs";
import 'core-js/es';
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';
React.Component.prototype.$qs = qs;

React.Component.prototype.$axios = Axios;

ReactDOM.render(<Provider store={store}>
  <BrowserRouter>
    <Route>
      <Switch>
        <Route path='/admin' render={
          (rootProps) => {
            return <App {...rootProps} />
          }
        } />

        {
          commonRoutes.map((item, index) => {
            return <Route path={item.pathname} component={item.component} key={index} />
          })
        }
        <Redirect from="/" to="/sign" exact></Redirect>
        <Redirect to="/404" exact></Redirect>
      </Switch>
    </Route>
  </BrowserRouter>
</Provider>,
  document.getElementById('root')
);
